package com.jianglin.state2.util;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jianglin.state2.model.core.PageParams;

import java.util.HashMap;
import java.util.Map;

/**
 * SQL工具类
 */
public class SqlUtil {
    public static Map<String, Object> getColumnMap(String key, Object value) {
        HashMap<String, Object> columnMap = new HashMap<>(1);
        columnMap.put(key, value);
        return columnMap;
    }

    public static Map<String, Object> getColumnMap() {
        return new HashMap<>(2);
    }

    public static <T> Page<T> getPage(PageParams pageParams) {
        Page<T> page = new Page<>();
        page.setCurrent(pageParams.getCurrentPage());
        if (pageParams.getPageSize() != null) {
            page.setSize(pageParams.getPageSize());
        } else {
            page.setSize(10);
        }
        return page;
    }
}
